package com.cjzuji.rental.controller.tool;

import com.aliyun.dysmsapi20170525.Client;
import com.aliyun.dysmsapi20170525.models.SendSmsRequest;
import com.aliyun.dysmsapi20170525.models.SendSmsResponse;
import com.aliyun.tea.TeaException;
import com.aliyun.teautil.models.RuntimeOptions;
import com.cjzuji.rental.Bean.ApiResponse;
import com.cjzuji.rental.Bean.ApiResponseCount;
import com.cjzuji.rental.Bean.request.tool.CreateSmsRequest;
import com.cjzuji.rental.Bean.request.tool.GetUserSmsList;
import com.cjzuji.rental.Config.AliSmsConfig;
import com.cjzuji.rental.pojo.UserSms;
import com.cjzuji.rental.service.ToolService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSON;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author bag
 * @version V1.0
 * @date 2025/6/12 15:19
 * @since 1.0
 */

@Slf4j
@RestController
@RequestMapping("/tool/sms")
@Api(tags = "短信发送类")
public class ToolController {

//    private static final Logger log = LoggerFactory.getLogger(ToolController.class);
    @Autowired
    private ToolService toolService;

    //http://127.0.0.1:9090/tool/sms/createSms
    @PostMapping("/createSms")
    @ApiOperation(value = "保存短信", notes = "保存审核员发送的短信")
    public ApiResponse<Boolean> saveSms(@RequestBody CreateSmsRequest createSmsRequest){
        log.info("打印数据");
        Boolean sms = toolService.createSms(createSmsRequest);
        if (sms){
            return ApiResponse.success(sms);
        }
        return ApiResponse.error("-1","保存信息失败!");
    }

    @PostMapping("/getUserSmsList")
    @ApiOperation(value = "获取发送短信列表", notes = "获取发送短信的信息列表")
    public ApiResponse<ApiResponseCount<UserSms>> getUserSmsList(@RequestBody GetUserSmsList getUserSmsList){
        ApiResponseCount<UserSms> userSmsApiResponseCount = toolService.userSmsList(getUserSmsList);
        return ApiResponse.success(userSmsApiResponseCount);
    }
}
